package com.itheima.service.db.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.itheima.domain.db.Freeze;
import com.itheima.mapper.FreezeMapper;
import com.itheima.service.db.FreezeService;
import org.apache.dubbo.config.annotation.Service;
import org.springframework.beans.factory.annotation.Autowired;

@Service
public class FreezeServiceImpl implements FreezeService {

    @Autowired
    private FreezeMapper freezeMapper;

    //用户冻结操作
    @Override
    public void save(Freeze freeze) {
        freezeMapper.insert(freeze);
    }

    //查freeze
    @Override
    public Freeze findByUserId(Long userId) {
        QueryWrapper queryWrapper = new QueryWrapper();
        queryWrapper.eq("user_id", userId);
        Freeze freeze = freezeMapper.selectOne(queryWrapper);
        return freeze;
    }

    //修改freeze表数据
    @Override
    public void update(Freeze freeze) {
        QueryWrapper queryWrapper = new QueryWrapper();
        queryWrapper.eq("user_id", freeze.getUserId());
        freezeMapper.update(freeze, queryWrapper);
    }


}
